Skip to content

Add RuleConventionsTest to enforce rule registration conventions#992

Open
mglaman wants to merge 4 commits into
mainfrom
claude/add-phpunit-drupal-rule-dv3Tp
Open

Add RuleConventionsTest to enforce rule registration conventions#992
mglaman wants to merge 4 commits into
mainfrom
claude/add-phpunit-drupal-rule-dv3Tp

Conversation

@mglaman
Copy link
Copy Markdown
Owner

@mglaman mglaman commented May 19, 2026

Adds tests/src/RuleConventionsTest.php which parses rules.neon,
extension.neon, and bleedingEdge.neon and asserts that every rule is
toggleable: registered via conditionalTags with a boolean default under
parameters.drupal.rules, opt-in rules enabled in bleedingEdge.neon, and
no new rules added directly under rules:. Graduated rules (default
true) are tracked via an explicit allowlist.

Fixes the pre-existing convention violation surfaced by the test:
pluginManagerInspectionRule was opt-in (false default) but missing from
bleedingEdge.neon.

Adds AGENTS.md documenting the conventions for contributors and agents,
and nette/neon as a dev dependency for parsing the neon files.

Closes #971

https://claude.ai/code/session_01AAChSrMEaL4S6st2ET2JRF

claude added 4 commits May 19, 2026 13:23
Adds tests/src/RuleConventionsTest.php which parses rules.neon,
extension.neon, and bleedingEdge.neon and asserts that every rule is
toggleable: registered via conditionalTags with a boolean default under
parameters.drupal.rules, opt-in rules enabled in bleedingEdge.neon, and
no new rules added directly under rules:. Graduated rules (default
true) are tracked via an explicit allowlist.

Fixes the pre-existing convention violation surfaced by the test:
pluginManagerInspectionRule was opt-in (false default) but missing from
bleedingEdge.neon.

Adds AGENTS.md documenting the conventions for contributors and agents,
and nette/neon as a dev dependency for parsing the neon files.

Closes #971

https://claude.ai/code/session_01AAChSrMEaL4S6st2ET2JRF
The rule is too unreliable to enable for bleeding-edge users. Instead of
adding it to bleedingEdge.neon, record the deliberate exception in
RuleConventionsTest::OPT_IN_RULES_EXCLUDED_FROM_BLEEDING_EDGE so the
conventions test stays green and the exclusion is explicit and
documented. Reverts the earlier bleedingEdge.neon addition and documents
the exception mechanism in AGENTS.md.

https://claude.ai/code/session_01AAChSrMEaL4S6st2ET2JRF
Drop the separate AGENTS.md and document the toggleable-rule conventions
in the existing CLAUDE.md instead. Update RuleConventionsTest failure
messages to point at CLAUDE.md.

https://claude.ai/code/session_01AAChSrMEaL4S6st2ET2JRF
Access the preg_match capture group only inside the `=== 1` branch so
PHPStan can prove the offset exists, instead of relying on an assertSame
that does not narrow the matches array.

https://claude.ai/code/session_01AAChSrMEaL4S6st2ET2JRF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add PHPUnit test to enforce rule registration conventions

2 participants